#include <memory>
#include "CommandServer.hpp"
#include "Command.hpp"
void Usage(std::string proc)
{
    std::cerr << "Usage : " << proc << " serverport" << std::endl;
}

// std::string CommandExec(const std::string commandstr)
// {
//     return "hello";
// }

// ./tcp_server serverport
int main(int argc, char *argv[])
{
    if (argc != 2)
    {
        Usage(argv[0]);
        exit(0);
    }
    EnableConsoleLogStrategy();
    uint16_t serverport = std::stoi(argv[1]);
    Command cmdobj;
    std::unique_ptr<CommandServer> ptr = std::make_unique<CommandServer>(
        [&cmdobj](const std::string &cmd) -> std::string
        {
            return cmdobj.Exec(cmd);
        },
        serverport);
    ptr->Init();
    ptr->Start();
    return 0;
}